package com.daigg.hoteladmin.controller;

import com.daigg.hoteladmin.pojo.po.HotelPO;
import com.daigg.hoteladmin.pojo.po.RoomTypePO;
import com.daigg.hoteladmin.pojo.vo.RoomTypeVO;
import com.daigg.hoteladmin.service.IRoomTypeServeice;
import com.daigg.hoteladmin.tools.Reply;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author daiyang
 * @Description: 房间类型Controller
 */
@Slf4j
@Api(tags = "04.房间类型相关接口")
@RestController
@RequestMapping("/api/roomType")
public class RoomTypeController {
    @Autowired
    IRoomTypeServeice roomTypeService;

    @PostMapping("/add")
    @ApiOperation("增加房间的类型")
    public Reply<RoomTypeVO> add(@RequestBody RoomTypeVO roomTypeVO) {

        return Reply.success(roomTypeService.add(roomTypeVO));
    }

    @GetMapping("/delete/{id}")
    @ApiOperation("删除房间的类型")
    public Reply deleteById(@PathVariable("id") String id) {
        return roomTypeService.deleteById(id) > 0 ? Reply.success() : Reply.failed();
    }

    @GetMapping("/get/{id}")
    @ApiOperation("根据id查找房的类型")
    public Reply<RoomTypeVO> selectById(@PathVariable("id") String id) {
        return Reply.success(roomTypeService.selectOneByIdReturnVO(id));
    }


    @PostMapping("/modify")
    @ApiOperation("更改房间类型")
    public Reply<RoomTypeVO> modify(@RequestBody RoomTypeVO roomTypeVO) {
        return Reply.success(roomTypeService.saveone(roomTypeVO));
    }

    // 获取房间类型列表(分页)
    // @PostMapping("page")
    // @ApiOperation("获取房间类型列表(分页)")
    // public Reply<Page<RoomTypeVO>> getPage(@RequestBody RoomTypeVO roomTypeVO){
    //     return Reply.success(roomTypeService.getPage(roomTypeVO));
    // }

    @GetMapping("/list")
    @ApiOperation("获取房间类型列表")
    public Reply<List<RoomTypePO>> getList() {
        log.debug("开始处理【获取房间类型列表】请求");
        List<RoomTypePO> list = roomTypeService.getList();
        log.debug("处理【获取房间类型列表】请求成功");
        return Reply.success(list);
    }


    @GetMapping("/currentRoomTypeList/{id}")
    @ApiOperation("获取当前酒店现有房间类型列表")
    public Reply<List<RoomTypeVO>> currentRoomTypeList(@PathVariable("id") String id,
                                                       @Param("isIsolation") Integer isIsolation) {
        return Reply.success(roomTypeService.currentRoomTypeList(id, isIsolation));
    }
}
